package form.contactlist;

import images.GetImage;

import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
public class ContactElement implements ListCellRenderer{
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		JPanel cont=new JPanel(new FlowLayout(FlowLayout.LEFT));
		cont.setBorder(BorderFactory.createLineBorder(Color.BLUE));
		
		Contact contact=(Contact)value;
		if(contact.isOnline())
			cont.add(new JLabel(new GetImage().getIcon("online.png")));
		else 
			cont.add(new JLabel(new GetImage().getIcon("offline.png")));
		cont.add(new JLabel(contact.getRealName()));
		cont.setToolTipText("<html><body bgcolor='white'><font color='black'>Nick name : </font><font color='blue'><b>"+
				contact.getNickName()+"</b></font></html>");
		if(isSelected)cont.setBackground(Color.GREEN);
		else cont.setBackground(list.getBackground());
		return cont;
	}

}
